/**
 * @program: LeetCode
 * @description: LeetCode :
 * @author: WXY
 * @create: 2022-12-26 11:37
 * @Version 1.0
 **/

public class two2_merge {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int[] arr = new int[m + n];
        int i = 0,j = 0;
        int index = 0;
        while (i < m && j < n) {
            arr[index++] = nums1[i] <= nums2[j] ? nums1[i++] : nums2[j++];
        }
        while (i < m) {
            arr[index++] = nums1[i++];
        }
        while (j < n) {
            arr[index++] = nums2[j++];
        }
        for (int k = 0; k < index; k++) {
            nums1[k] = arr[k];
        }
    }
}
